package com.panshi.modules.common.user;


import com.panshi.api.UserPoth;
import com.panshi.api.util.CommonResult;
import com.panshi.bean.PageSizeVO;
import com.panshi.bean.UserVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @author :jiege
 * @description :
 * @create :2020-08-19 14:25:00
 */
@Controller
@Api(tags = "会员查询接口")
public class UserController {
    @Autowired
   private UserPoth userPoth;


    @GetMapping("/user/list")
    @ApiOperation(value = "用户页面")
    @RequiresPermissions("user:list")
    public ModelAndView unanswerpage(){
        return new ModelAndView("/user/user-list");
    }

    @GetMapping("/user/userlist")
    @ResponseBody
    @RequiresPermissions("user:list")
    @ApiOperation(value = "会员数据查询")
    public PageSizeVO<List<UserVO>> querymyanswerlist(Integer currentPage, Integer pageSize){
        System.out.println(currentPage+"============"+pageSize);
        PageSizeVO<String> pageSizeBean = new PageSizeVO<>();
        pageSizeBean.setStartIndex(currentPage);
        pageSizeBean.setPageSize(pageSize);
        return  userPoth.findUserQueryList(pageSizeBean);
    }

    @GetMapping("/user/updatestate")
    @ResponseBody
    @RequiresPermissions("user:update")
    @ApiOperation(value = "会员状态修改")
    public CommonResult<String> updatestate(UserVO userVO){
        userPoth.updateUser(userVO);
        return new CommonResult<String>();
    }

}
